package com.xsomnus.mc.kafka.consumer.components;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019/4/26 0026 17:56
 * 当你发现自己的才华撑不起野心时，就请安静下来学习吧
 * 经过过滤器处理之后的数据监听
 */
@Slf4j
@Component
public class FilterListener {
    @KafkaListener(topics = {"filter_topic"}, containerFactory = "filterContainerFactory")
    public void consumerBatch(ConsumerRecord<?, ?> record) {
        Optional<?> kafkaMessage = Optional.ofNullable(record.value());
        if (kafkaMessage.isPresent()) {
            Object message = kafkaMessage.get();
            log.info("record =" + record);
            log.info("接收到消息数量：{}", message);
        }

    }
}
